<template>
  <el-dialog
    v-model="openDialog"
    @closed="handleClose"
    :title="`${isEdit ? '添加' : '查看'}角色`"
    width="600px"
  >
    <el-form
      :model="formData"
      label-width="120px"
      ref="formData"
      :rules="rules"
    >
      <el-form-item label="角色名称：" prop="roleName">
        <el-input
          v-model="formData.roleName"
          style="width: 300px"
          :readonly="!isEdit"
          maxlength="30"
        />
      </el-form-item>
      <el-form-item label="角色编码：" prop="roleCode">
        <el-input
          v-model="formData.roleCode"
          style="width: 300px"
          :readonly="!isEdit"
        />
      </el-form-item>
      <el-form-item label="状态：" prop="state">
        <el-radio-group v-model="formData.state">
          <el-radio :label="3">启用</el-radio>
          <el-radio :label="6">停用</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="角色类型：" prop="roleType">
        <el-radio-group v-model="formData.roleType">
          <el-radio :label="3">普通角色</el-radio>
          <el-radio :label="6">分级管理员</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="公司：">
        <el-select
          v-model="formData.company"
          style="width: 300px"
          :readonly="!isEdit"
        >
          <el-option label="中储南京智慧物流有限公司" value="shanghai" />
          <el-option label="金湖分公司" value="beijing" />
        </el-select>
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button type="primary" @click="confirm">保存</el-button>
      <el-button @click="handleClose">取消</el-button>
    </template>
  </el-dialog>
</template>

<script>
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import Search from "@iconify-icons/ep/search";
export default {
  name: "jobsTreeTransfer",

  components: {},
  props: {
    // 是否编辑
    isEdit: {
      type: Boolean,
      default: false
    },
    row: {
      default: {}
    }
  },
  data() {
    return {
      Search,
      openDialog: false,
      formData: {
        userName: "",
        gruopers: []
      },
      rules: {
        roleName: [
          { required: true, message: "请输入角色名称", trigger: "change" }
        ],
        roleCode: [
          { required: true, message: "请输入角色编码", trigger: "change" }
        ]
      }
    };
  },

  methods: {
    useRenderIcon,
    onChangeVisible() {
      this.openDialog = true;
    },

    confirm() {
      this.$refs.formData.validate(valid => {
        if (valid) {
          this.openDialog = false;
        }
      });
    },
    handleClose() {
      this.formData = {};
      this.$refs.formData.clearValidate();
      this.openDialog = false;
    }
  },

  mounted() {}
};
</script>

<style lang="scss" scoped></style>
